package com.qk.management.mapper;

import com.qk.domain.user.UserDO;
import com.qk.entity.User;
import org.apache.ibatis.annotations.*;

import java.time.LocalDate;
import java.util.List;

import com.qk.dto.user.UserDto;

/**
 * 用户数据访问接口
 */
@Mapper
public interface UserMapper {

    /**
     * 动态条件分页查询用户列表
     */
    List<UserDO> getUsers(UserDto userDto);


    void insert(User user);


    void deleteByIds(List<Integer> ids);

    @Select("SELECT * FROM user WHERE id = #{id}")
    User select(Integer id);

    void update(User user);

    @Select("SELECT * FROM user WHERE dept_id = #{id}")
    List<User> selectUserByDept(Integer id);

    @Select("SELECT * FROM user WHERE username = #{username}")
    User getUserByUsername(String username);

    @Select("SELECT * FROM user")
    List<User> selectAllUser();

    List<User> selectUserByRole(String  role);

    /**
     * 根据更新时间查询用户头像URL列表
     * @param today 查询的起始日期（包含）
     * @return 用户头像URL列表
     */
    @Select("SELECT image FROM user where update_time >= #{today}")
    List<String> selectAvatarUrls(@Param("today") LocalDate today);

}